<?php
require_once dirname(__DIR__) . '/public/cli.php';

use Yaf\Application;
use Yaf\Request\Simple;

/**
 * 测试OneBot机器人消息
 */
$app = new Application(APPLICATION_PATH . "/conf/application.ini");
$app->bootstrap();

/**
 * 生成参数
 */
$config = include APPLICATION_PATH . '/conf/'.ini_get('yaf.environ').'/bot.php';
$config = $config['qq'];
$token = $config['token'];
$data = [
    'message_type' => 'private',
    'id'           => 367013672,
    'message'      => date('Y-m-d H:i:s'),
    'time'         => time(),
    //'sign'         => ''
];
$data['sign'] = md5($token . $data['message_type'] . $data['id'] . $data['message'] . $data['time'] . $token);
// 1. 测试单例，静态方法
$resp = ICurl::post('https://movie.iyuu.cn/Bot/send', $data, true);
p($resp, true);


$data['message_type'] = 'group';
$data['id'] = 41477250;
$data['sign'] = md5($token . $data['message_type'] . $data['id'] . $data['message'] . $data['time'] . $token);
$resp = ICurl::http_post('https://movie.iyuu.cn/Bot/send', $data, false);
p($resp, true);

// 2. 测试单例，委托
//$resp = ICurl::one()->get('https://api.iyuu.cn');
//$resp = ICurl::one()->post('https://movie.iyuu.cn/Bot/send', $data);


// 3. 测试本地
//$resp = ICurl::post('http://yaf.com/Movie/index', $data, false);
//$resp = ICurl::http_post('http://yaf.com/Index/test', 'abc=123');


/**
 * 测试Yaf的CLI模式路由
 */
$app->getDispatcher()->dispatch(new Simple('GET', 'Index', 'Movie', 'index', $data));
